<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="container">
        <p>1111</p>
        <p>2222</p>
        <p>3333</p>
    </div>
    <script>
      //删除元素
      //1、父元素.removeChild(子元素)
    //  var doms =  [...document.querySelectorAll('.container,.container>p:nth-of-type(2)')]
    //  document.onclick=function(){
    //     if(doms[1]){
    //         doms[0].removeChild(doms[1])
    //        doms.length =1        
    //     } 
    //  }
     //二、删除自身  自身元素.remove() (用得多)
     var p = document.getElementsByTagName('p')[1]
     document.onclick=function(){
        p.remove()
     }
    </script>
</body>
</html>